package com.qiangesoft.miniapp.config.ma.store;

import cn.binarywang.wx.miniapp.config.WxMaConfig;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import com.qiangesoft.miniapp.properties.WxMaProperties;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 内存缓存配置
 *
 * @author qiangesoft
 * @since 2024-07-16
 */
@Configuration
@ConditionalOnProperty(prefix = WxMaProperties.PREFIX + ".config-storage", name = "type", matchIfMissing = true, havingValue = "memory")
@RequiredArgsConstructor
public class MemoryWxMaStorageConfiguration extends AbstractWxMaStorageConfiguration {

    private final WxMaProperties wxMaProperties;

    @Bean
    @ConditionalOnMissingBean(WxMaConfig.class)
    public WxMaConfig wxMaConfig() {
        WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
        return this.config(config, wxMaProperties);
    }

}

